<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script src="{{ getAssets }}js/jquery.table2excel.min.js?v={{ assets_version }}"></script>
<script>
    var entry_id = '{{.m.Id}}';
    var tables = $('#dataTables').DataTable({
        "sAjaxSource" : '{{ urlfor "EntryreturnController.EntryreturnData"}}'
        ,"bLengthChange": false
        ,"fnServerData" : function(sSource, aoData, fnCallback) {
            var params = checkQueryTableData(aoData);
            params.entry_id = Number(entry_id);
            $.post(sSource, params,function(resp) {
                fnCallback(resp);
            },'json');
        }
        ,order:[]
        ,columns: [
            {"bSortable": false, render:function(data, type, full, meta) {
                    return '<div align="left" style="padding-left:3px"><input type="checkbox" class="selectOne" value="'+ meta.row +'"></div>';
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return productGroupName(full.Products);
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.sph;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.cyl;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.add;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.model;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.color;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.size;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.function_info;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.film_color;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Snd.genre;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Products.Spec;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Acceptance.lot_number;
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Acceptance.manufacture_date > 0 ? timetransDate(full.Acceptance.manufacture_date) : '';
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Acceptance.expiry_date > 0 ? timetransDate(full.Acceptance.expiry_date) : '';
                }}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return '<input type="hidden" id="o-purchase-'+ full.Id +'" value="'+ full.purchase_num +'">' + full.purchase_num;
                }}
        ]
        ,"aLengthMenu":[20, 50, 100, 200]
		,'bLengthChange': true
        ,"serverSide": true
        ,"bPaginate" : false
        ,"bFilter" : false	//是否启动过滤、搜索功能
        ,"bInfo" : false //是否显示页脚信息，DataTables插件左下角显示记录数
        ,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示
        ,"drawCallback": function(settings){
        }
    });
    $('#download').bind("click", function(){
        $("#dataTables").table2excel({
            // 不被导出的表格行的CSS class类
            exclude: ".noExl",
            // 导出的Excel文档的名称
            name: "Excel Document Name",
            // Excel文件的名称
            filename: "退货明细",
            //文件后缀名
            fileext: ".xls",
            //是否排除导出图片
            exclude_img: false,
            //是否排除导出超链接
            exclude_links: false,
            //是否排除导出输入框中的内容
            exclude_inputs: false
        });
        return false;
    });
</script>